package com.yyc.stocktake.api

import com.yyc.stocktake.bean.BaseListBean
import com.yyc.stocktake.bean.BaseResponseBean
import com.yyc.stocktake.bean.DataBean
import com.yyc.stocktake.bean.db.OrderBean
import com.yyc.stocktake.util.CacheUtil
import okhttp3.ResponseBody
import retrofit2.http.*


/**
 * Created by xuhao on 2017/11/16.
 * Api 接口
 */

interface ApiService{

    companion object {

        private val url =
//            "192.168.2.18"
            "47.243.120.137"

        var SERVLET_URL = "http://" +
                url + "/RFIDInventoryWebServiceV2/"

        private const val asmx = "MobileWebService.asmx/"
    }

    //登录
    @FormUrlEncoded
    @POST("$asmx" + "CheckLogin")
    suspend fun CheckLogin(
        @Field("companyID") companyID: String,
        @Field("loginID") loginID: String,
        @Field("userPwd") userPwd: String
    ): BaseResponseBean<DataBean>

    //盘点列表
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeList")
    suspend fun stockTakeList(
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<ArrayList<OrderBean>>

    // Rfid列表
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeListAsset")
    suspend fun stockTakeListAsset(
        @Field("orderno") orderno: String,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    //上传图片
    @Headers("Content-Type: application/x-www-form-urlencoded")
    @FormUrlEncoded
    @POST("$asmx" + "UploadStockTake")
    suspend fun FileToByte(
        @Field("companyID") UnitCode: String?,
        @Field("strJson") strJson: String
    ): BaseResponseBean<DataBean>

}